<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设置剪贴板</title>
</head>
<body>
    <button onclick="setClipboardText('剪贴板设置成功，请按Ctrl+v查看！')">设置剪贴板</button>

<script>
    function setClipboardText(val){
        const text = document.createElement('textarea');
        text.value = val;
        document.body.appendChild(text);
        text.select();
        document.execCommand('Copy');
        text.remove();
        console.log('剪贴板设置成功，请按Ctrl+v查看！');
    }
</script>
</body>
</html>